package com.wolfsea.defineviewpageindicator
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View

/*
* 多点触摸(各自为战):每根按下的手指都会起作用
* */
class MultiTouchView3 @JvmOverloads constructor(
    context: Context,
    attributeSet: AttributeSet? = null
) : View(context, attributeSet) {

    override fun onTouchEvent(event: MotionEvent?): Boolean {
        performClick()
        when (event?.actionMasked) {
            MotionEvent.ACTION_DOWN,
            MotionEvent.ACTION_POINTER_DOWN -> {
                val actionIndex = event.actionIndex
                val actionId = event.getPointerId(actionIndex)
                val downX = event.getX(actionIndex)
                val downY = event.getY(actionIndex)
            }
            MotionEvent.ACTION_MOVE -> {
                for (i in 0.until(event.pointerCount)) {
                    val moveX = event.getX(i)
                    val moveY = event.getY(i)
                }
                invalidate()
            }
            MotionEvent.ACTION_POINTER_UP,
            MotionEvent.ACTION_UP -> {
                val pointerId = event.getPointerId(event.actionIndex)
                invalidate()
            }
        }
        return true
    }

    override fun performClick(): Boolean {
        return super.performClick()
    }

}